       section   code
       xdef      _ReadSwAll
_ReadSwAll:
       link      A6,#-4
       move.b    57345,-1(A6)
       move.b    -1(A6),D0
       unlk      A6
       rts
       xdef      _ReadSwN
_ReadSwN:
       link      A6,#0
       movem.l   D2,-(A7)
       move.b    11(A6),D0
       and.l     #255,D0
       cmp.l     #7,D0
       bls.s     ReadSwN_1
       move.b    #255,D2
       bra.s     ReadSwN_3
ReadSwN_1:
       move.b    57345,D0
       and.l     #255,D0
       moveq     #1,D1
       move.l    D0,-(A7)
       move.b    11(A6),D0
       and.l     #255,D0
       asl.l     D0,D1
       move.l    (A7)+,D0
       and.l     D1,D0
       move.b    D0,D2
       and.l     #255,D2
       beq.s     ReadSwN_3
       moveq     #1,D2
ReadSwN_3:
       move.b    D2,D0
ReadSwN_5:
       movem.l   (A7)+,D2
       unlk      A6
       rts
       xdef      _ReadLedAll
_ReadLedAll:
       link      A6,#-4
       move.b    57347,-1(A6)
       move.b    -1(A6),D0
       unlk      A6
       rts
       xdef      _ReadLedN
_ReadLedN:
       link      A6,#0
       movem.l   D2,-(A7)
       move.b    11(A6),D0
       and.l     #255,D0
       cmp.l     #7,D0
       bls.s     ReadLedN_1
       move.b    #255,D2
       bra.s     ReadLedN_3
ReadLedN_1:
       move.b    57347,D0
       and.l     #255,D0
       moveq     #1,D1
       move.l    D0,-(A7)
       move.b    11(A6),D0
       and.l     #255,D0
       asl.l     D0,D1
       move.l    (A7)+,D0
       and.l     D1,D0
       move.b    D0,D2
       and.l     #255,D2
       beq.s     ReadLedN_3
       moveq     #1,D2
ReadLedN_3:
       move.b    D2,D0
ReadLedN_5:
       movem.l   (A7)+,D2
       unlk      A6
       rts
       xdef      _WriteLedAll
_WriteLedAll:
       link      A6,#0
       move.b    11(A6),57347
       unlk      A6
       rts
       xdef      _WriteLedN
_WriteLedN:
       link      A6,#-4
       movem.l   D2/D3,-(A7)
       move.b    11(A6),D3
       and.l     #255,D3
       and.l     #255,D3
       cmp.l     #7,D3
       bls.s     WriteLedN_1
       moveq     #1,D2
       bra       WriteLedN_4
WriteLedN_1:
       move.b    15(A6),D0
       and.l     #255,D0
       cmp.l     #1,D0
       bls.s     WriteLedN_3
       moveq     #2,D2
       bra       WriteLedN_4
WriteLedN_3:
       move.b    15(A6),D0
       and.l     #255,D0
       cmp.l     #1,D0
       bne.s     WriteLedN_5
       move.b    57347,D0
       and.l     #255,D0
       moveq     #1,D1
       and.l     #255,D3
       asl.l     D3,D1
       or.l      D1,D0
       move.b    D0,57347
       bra.s     WriteLedN_6
WriteLedN_5:
       move.b    57347,D0
       and.l     #255,D0
       moveq     #1,D1
       and.l     #255,D3
       asl.l     D3,D1
       not.l     D1
       and.l     D1,D0
       move.b    D0,57347
WriteLedN_6:
       clr.b     D2
WriteLedN_4:
       move.b    D2,D0
WriteLedN_7:
       movem.l   (A7)+,D2/D3
       unlk      A6
       rts
       xdef      _ReadSlider
_ReadSlider:
       link      A6,#-4
       move.b    57349,-1(A6)
       move.b    -1(A6),D0
       unlk      A6
       rts
       xdef      _WriteBar
_WriteBar:
       link      A6,#0
       move.b    11(A6),57351
       unlk      A6
       rts
       xdef      _WriteDigitN
_WriteDigitN:
       link      A6,#0
       movem.l   D2/D3/D4/A2/A3,-(A7)
       move.b    15(A6),D2
       and.l     #255,D2
       lea       @io68k_SegmentTable,A2
       lea       @io68k_bcd2Segment,A3
       move.b    11(A6),D4
       and.l     #255,D4
       and.l     #255,D4
       cmp.l     #3,D4
       bls.s     WriteDigitN_1
       moveq     #1,D3
       bra       WriteDigitN_4
WriteDigitN_1:
       and.l     #255,D2
       cmp.l     #9,D2
       bls.s     WriteDigitN_3
       moveq     #3,D3
       bra       WriteDigitN_4
WriteDigitN_3:
       and.l     #255,D4
       bne.s     WriteDigitN_5
       move.b    57361,D0
       and.l     #255,D0
       and.l     #128,D0
       move.l    D0,-(A7)
       move.l    A2,-(A7)
       and.l     #255,D2
       move.l    D2,-(A7)
       jsr       (A3)
       addq.w    #8,A7
       move.l    D0,D1
       move.l    (A7)+,D0
       and.l     #255,D1
       or.l      D1,D0
       move.b    D0,57361
       bra       WriteDigitN_10
WriteDigitN_5:
       and.l     #255,D4
       cmp.l     #1,D4
       bne.s     WriteDigitN_7
       move.b    57363,D0
       and.l     #255,D0
       and.l     #128,D0
       move.l    D0,-(A7)
       move.l    A2,-(A7)
       and.l     #255,D2
       move.l    D2,-(A7)
       jsr       (A3)
       addq.w    #8,A7
       move.l    D0,D1
       move.l    (A7)+,D0
       and.l     #255,D1
       or.l      D1,D0
       move.b    D0,57363
       bra       WriteDigitN_10
WriteDigitN_7:
       and.l     #255,D4
       cmp.l     #2,D4
       bne.s     WriteDigitN_9
       move.b    57365,D0
       and.l     #255,D0
       and.l     #128,D0
       move.l    D0,-(A7)
       move.l    A2,-(A7)
       and.l     #255,D2
       move.l    D2,-(A7)
       jsr       (A3)
       addq.w    #8,A7
       move.l    D0,D1
       move.l    (A7)+,D0
       and.l     #255,D1
       or.l      D1,D0
       move.b    D0,57365
       bra.s     WriteDigitN_10
WriteDigitN_9:
       move.b    57367,D0
       and.l     #255,D0
       and.l     #128,D0
       move.l    D0,-(A7)
       move.l    A2,-(A7)
       and.l     #255,D2
       move.l    D2,-(A7)
       jsr       (A3)
       addq.w    #8,A7
       move.l    D0,D1
       move.l    (A7)+,D0
       and.l     #255,D1
       or.l      D1,D0
       move.b    D0,57367
WriteDigitN_10:
       clr.b     D3
WriteDigitN_4:
       move.b    D3,D0
WriteDigitN_11:
       movem.l   (A7)+,D2/D3/D4/A2/A3
       unlk      A6
       rts
       xdef      _WriteDigitAll
_WriteDigitAll:
       link      A6,#0
       movem.l   D2/D3,-(A7)
       move.w    10(A6),D0
       and.l     #65535,D0
       cmp.l     #9999,D0
       bls.s     WriteDigitAll_1
       moveq     #3,D3
       bra       WriteDigitAll_2
WriteDigitAll_1:
       move.w    10(A6),D1
       and.l     #65535,D1
       move.l    D1,-(A7)
       bsr       @io68k_bin2Bcd
       addq.w    #4,A7
       clr.b     D2
WriteDigitAll_3:
       and.l     #255,D2
       cmp.l     #4,D2
       bhs.s     WriteDigitAll_5
       and.l     #255,D2
       lea       @io68k_BcdArray,A0
       move.b    0(A0,D2.L),D1
       and.l     #255,D1
       move.l    D1,-(A7)
       and.l     #255,D2
       move.l    D2,-(A7)
       bsr       _WriteDigitN
       addq.w    #8,A7
WriteDigitAll_4:
       addq.b    #1,D2
       bra       WriteDigitAll_3
WriteDigitAll_5:
       clr.b     D3
WriteDigitAll_2:
       move.b    D3,D0
WriteDigitAll_6:
       movem.l   (A7)+,D2/D3
       unlk      A6
       rts
       xdef      _WriteDigitPointN
_WriteDigitPointN:
       link      A6,#0
       movem.l   D2/D3,-(A7)
       move.b    11(A6),D2
       and.l     #255,D2
       and.l     #255,D2
       cmp.l     #3,D2
       bls.s     WriteDigitPointN_1
       moveq     #1,D3
       bra       WriteDigitPointN_4
WriteDigitPointN_1:
       move.b    15(A6),D0
       and.l     #255,D0
       cmp.l     #1,D0
       bls.s     WriteDigitPointN_3
       moveq     #2,D3
       bra       WriteDigitPointN_4
WriteDigitPointN_3:
       move.b    15(A6),D0
       and.l     #255,D0
       cmp.l     #1,D0
       bne       WriteDigitPointN_5
       and.l     #255,D2
       bne.s     WriteDigitPointN_7
       move.b    57361,D0
       and.l     #255,D0
       or.l      #128,D0
       move.b    D0,57361
       bra       WriteDigitPointN_12
WriteDigitPointN_7:
       and.l     #255,D2
       cmp.l     #1,D2
       bne.s     WriteDigitPointN_9
       move.b    57363,D0
       and.l     #255,D0
       or.l      #128,D0
       move.b    D0,57363
       bra.s     WriteDigitPointN_12
WriteDigitPointN_9:
       and.l     #255,D2
       cmp.l     #2,D2
       bne.s     WriteDigitPointN_11
       move.b    57365,D0
       and.l     #255,D0
       or.l      #128,D0
       move.b    D0,57365
       bra.s     WriteDigitPointN_12
WriteDigitPointN_11:
       move.b    57367,D0
       and.l     #255,D0
       or.l      #128,D0
       move.b    D0,57367
WriteDigitPointN_12:
       bra       WriteDigitPointN_18
WriteDigitPointN_5:
       and.l     #255,D2
       bne.s     WriteDigitPointN_13
       move.b    57361,D0
       and.l     #255,D0
       and.l     #127,D0
       move.b    D0,57361
       bra       WriteDigitPointN_18
WriteDigitPointN_13:
       and.l     #255,D2
       cmp.l     #1,D2
       bne.s     WriteDigitPointN_15
       move.b    57363,D0
       and.l     #255,D0
       and.l     #127,D0
       move.b    D0,57363
       bra.s     WriteDigitPointN_18
WriteDigitPointN_15:
       and.l     #255,D2
       cmp.l     #2,D2
       bne.s     WriteDigitPointN_17
       move.b    57365,D0
       and.l     #255,D0
       and.l     #127,D0
       move.b    D0,57365
       bra.s     WriteDigitPointN_18
WriteDigitPointN_17:
       move.b    57367,D0
       and.l     #255,D0
       and.l     #127,D0
       move.b    D0,57367
WriteDigitPointN_18:
       clr.b     D3
WriteDigitPointN_4:
       move.b    D3,D0
WriteDigitPointN_19:
       movem.l   (A7)+,D2/D3
       unlk      A6
       rts
@io68k_bin2Bcd:
       link      A6,#0
       movem.l   D2,-(A7)
       moveq     #3,D2
@io68k_bin2Bcd_1:
       ext.w     D2
       ext.l     D2
       cmp.l     #0,D2
       blt.s     @io68k_bin2Bcd_3
       move.w    10(A6),D0
       divu.w    #10,D0
       swap      D0
       and.l     #65535,D0
       ext.w     D2
       ext.l     D2
       lea       @io68k_BcdArray,A0
       move.b    D0,0(A0,D2.L)
       move.l    10(A6),-(A7)
       pea       10
       bsr       ULDIV
       move.l    (A7),10(A6)
       addq.w    #8,A7
@io68k_bin2Bcd_2:
       subq.b    #1,D2
       bra       @io68k_bin2Bcd_1
@io68k_bin2Bcd_3:
       movem.l   (A7)+,D2
       unlk      A6
       rts
@io68k_bcd2Segment:
       link      A6,#-4
       move.l    12(A6),A0
       move.b    11(A6),D0
       and.l     #255,D0
       move.b    0(A0,D0.L),-1(A6)
       move.b    -1(A6),D0
       unlk      A6
       rts
       section   data
@io68k_SegmentTable:
       dc.b      63,6,91,79,102,109,125,7,127,111
       section   bss
@io68k_BcdArray:
       ds.b      4
       xref      ULDIV
